package Tasks;

import AI.AiEntity;

public class Attack extends Task
{
	AiEntity enemy;
	
	public Attack(AiEntity e)
	{
		urgency = 3;
		this.enemy = e;
		finished = false;
	}
	
	@Override
	public void performTask(AiEntity e) 
	{
		if(enemy.health > 0)
		{
			if(Math.abs(e.getX()-enemy.getX()) <= 1 && Math.abs(e.getY()-enemy.getY()) <= 1)
			{
				e.setDestination(e.getX(), e.getY());
				e.attack(enemy);
			}
			else
			{
				System.out.println("1");
				e.setDestination(enemy.getX(), enemy.getY());
				System.out.println(e.currentPath.getSize());
			}
		}
		else
		{	
			finished = true;
		}
	}

	@Override
	public boolean isFinished(AiEntity e) 
	{
		return finished;
	}
	
}
